package dr.mini.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import dr.mini.domain.MemberCommand;

public class MemberValidator implements Validator {

	public boolean supports(Class<?> clazz) {
		return MemberCommand.class.isAssignableFrom(clazz);
	}

	public void validate(Object target, Errors errors) {
		MemberCommand command = (MemberCommand) target;
		System.out.println(command);
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"id", "required.member.id");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"passwd", "required.member.passwd");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors,"name", "required.member.name");
	}
}
